home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / file-tra / fsp-2.7 / fsp-2 / fsp / include / vms / wait.h < prev   
Encoding:
C/C++ Source or Header  |  1993-05-07  |  5.4 KB  |  166 lines

  1. /*    @(#)wait.h    4.2    (ULTRIX)    9/4/90    */
  2. /* ------------------------------------------------------------------------
  3.  * Modification History: /sys/h/wait.h
  4.  *
  5.  * 20-Dec-89  scott
  6.  *    added #ifdef's for xopen, posix compliance
  7.  *
  8.  */
  9.  
  10. #ifndef _WAIT_H_
  11. #define _WAIT_H_
  12.  
  13. #ifndef VMS
  14. #ifdef KERNEL
  15. #include "../h/ansi_compat.h"
  16. #else
  17. #include <ansi_compat.h>
  18. #endif
  19. #else /* !VMS */
  20. #define __vax 1
  21. #endif
  22.  
  23. /*
  24.  * This file holds definitions relevent to the wait system call.
  25.  * Some of the options here are available only through the ``wait3''
  26.  * entry point; the old entry point with one argument has more fixed
  27.  * semantics, never returning status of unstopped children, hanging until
  28.  * a process terminates if any are outstanding, and never returns
  29.  * detailed information about process resource utilization (<vtimes.h>).
  30.  */
  31.  
  32. /*
  33.  * Structure of the information in the first word returned by both
  34.  * wait and wait3.  If w_stopval==WSTOPPED, then the second structure
  35.  * describes the information returned, else the first.  See WUNTRACED below.
  36.  */
  37.  
  38. #ifdef __mips
  39. /*
  40.  * The structures returned by wait() are defined by bit field names
  41.  * in 4.2BSD, although not used consistently. In system V, the definition
  42.  * is by byte and bit positions (gak!). We try to satisfy both by
  43.  * conditionaly compiling the 4.2 bit fields to line up with the
  44.  * system V position scheme.
  45.  */
  46. #endif /* __mips */
  47.  
  48. #if !defined(_POSIX_SOURCE)
  49. union wait {
  50. #else
  51. union __wait    {
  52. #endif /* !defined(_POSIX_SOURCE) */
  53. #ifdef __vax
  54.     int    w_status;        /* used in syscall */
  55. #endif /* __vax */
  56. #ifdef __mips
  57.     unsigned int    w_status;        /* used in syscall */
  58. #endif /* __mips */
  59.     /*
  60.      * Terminated process status.
  61.      */
  62.     struct {
  63. #ifdef __vax
  64.         unsigned short    w_Termsig:7;    /* termination signal */
  65.         unsigned short    w_Coredump:1;    /* core dump indicator */
  66.         unsigned short    w_Retcode:8;    /* exit code if w_termsig==0 */
  67. #endif /* __vax */
  68. #ifdef __mips
  69. #ifdef __MIPSEL
  70.         unsigned int    w_Termsig:7;    /* termination signal */
  71.         unsigned int    w_Coredump:1;    /* core dump indicator */
  72.         unsigned int    w_Retcode:8;    /* exit code if w_termsig==0 */
  73.         unsigned int    w_Filler:16;    /* pad to word boundary */
  74. #endif /* __MIPSEL */
  75. #ifdef __MIPSEB
  76.         unsigned int    w_Filler:16;    /* pad to word boundary */
  77.         unsigned int    w_Retcode:8;    /* exit code if w_termsig==0 */
  78.         unsigned int    w_Coredump:1;    /* core dump indicator */
  79.         unsigned int    w_Termsig:7;    /* termination signal */
  80. #endif /* __MIPSEB */
  81. #endif /* __mips */
  82.     } w_T;
  83.     /*
  84.      * Stopped process status.  Returned
  85.      * only for traced children unless requested
  86.      * with the WUNTRACED option bit.
  87.      */
  88.     struct {
  89. #ifdef __vax
  90.         unsigned short    w_Stopval:8;    /* == W_STOPPED if stopped */
  91.         unsigned short    w_Stopsig:8;    /* signal that stopped us */
  92. #endif /* __vax */
  93. #ifdef __mips
  94. #ifdef __MIPSEL
  95.         unsigned int    w_Stopval:8;    /* == W_STOPPED if stopped */
  96.         unsigned int    w_Stopsig:8;    /* signal that stopped us */
  97.         unsigned int    w_Filler:16;    /* pad to word boundary */
  98. #endif /* __MIPSEL */
  99. #ifdef __MIPSEB
  100.         unsigned int    w_Filler:16;    /* pad to word boundary */
  101.         unsigned int    w_Stopsig:8;    /* signal that stopped us */
  102.         unsigned int    w_Stopval:8;    /* == W_STOPPED if stopped */
  103. #endif /* __MIPSEB */
  104. #endif /* __mips */
  105.     } w_S;
  106. };
  107.  
  108. #if !defined(_POSIX_SOURCE)
  109. #define    w_termsig    w_T.w_Termsig
  110. #define w_coredump    w_T.w_Coredump
  111. #define w_retcode    w_T.w_Retcode
  112. #define w_stopval    w_S.w_Stopval
  113. #define w_stopsig    w_S.w_Stopsig
  114. #define    WSTOPPED    0177    /* value of s.stopval if process is stopped */
  115. #endif /* !defined(_POSIX_SOURCE) */
  116.  
  117. #ifdef  WSTOPPED
  118. #define _WSTOPPED    WSTOPPED
  119. #else
  120. #define _WSTOPPED    0177
  121. #endif
  122.  
  123. /*
  124.  * Option bits for the second argument of wait3.  WNOHANG causes the
  125.  * wait to not hang if there are no stopped or terminated processes, rather
  126.  * returning an error indication in this case (pid==0).  WUNTRACED
  127.  * indicates that the caller should receive status about untraced children
  128.  * which stop due to signals.  If children are stopped and a wait without
  129.  * this option is done, it is as though they were still running... nothing
  130.  * about them is returned.
  131.  */
  132. #define WNOHANG        1    /* dont hang in wait */
  133. #define WUNTRACED    2    /* tell about stopped, untraced children */
  134.  
  135. /*
  136.  * Must cast as union wait * because POSIX defines the input to these macros
  137.  * as int.
  138.  */
  139.  
  140. #ifdef _POSIX_SOURCE
  141. #define WIFSTOPPED(x)    (((union __wait *)&(x))->w_S.w_Stopval == _WSTOPPED)
  142. #define WIFSIGNALED(x)    (((union __wait *)&(x))->w_S.w_Stopval != _WSTOPPED && ((union __wait *)&(x))->w_T.w_Termsig != 0)
  143. #define WIFEXITED(x)    (((union __wait *)&(x))->w_S.w_Stopval != _WSTOPPED && ((union __wait *)&(x))->w_T.w_Termsig == 0)
  144. #define    WEXITSTATUS(x)    (((union __wait *)&(x))->w_T.w_Retcode)
  145. #define    WTERMSIG(x)    (((union __wait *)&(x))->w_T.w_Termsig)
  146. #define    WSTOPSIG(x)    (((union __wait *)&(x))->w_S.w_Stopsig)
  147. #endif /* _POSIX_SOURCE */
  148.  
  149. #if !defined(_POSIX_SOURCE)
  150. #define WIFSTOPPED(x)    (((union wait *)&(x))->w_stopval == WSTOPPED)
  151. #define WIFSIGNALED(x)    (((union wait *)&(x))->w_stopval != WSTOPPED && ((union wait *)&(x))->w_termsig != 0)
  152. #define WIFEXITED(x)    (((union wait *)&(x))->w_stopval != WSTOPPED && ((union wait *)&(x))->w_termsig == 0)
  153. #define    WEXITSTATUS(x)    (((union wait *)&(x))->w_retcode)
  154. #define    WTERMSIG(x)    (((union wait *)&(x))->w_termsig)
  155. #define    WSTOPSIG(x)    (((union wait *)&(x))->w_stopsig)
  156. #endif /* !defined(_POSIX_SOURCE) */
  157.  
  158. #ifndef VMS
  159. #ifndef    KERNEL
  160. #include    <sys/types.h>    /* Old programs don't do this */
  161. pid_t wait(), waitpid();
  162. #endif    /* KERNEL */
  163. #endif /* !VMS */
  164.  
  165. #endif /* _WAIT_H_ */
  166.